package com.qf.shop.dao.Impl;

import com.qf.shop.dao.TypeDao;
import com.qf.shop.entity.Type;
import com.qf.shop.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class TypeDaoImpl implements TypeDao {
    private QueryRunner queryRunner = new QueryRunner();
    @Override
    public List<Type> selectAll() {
        try {
            return  queryRunner.query(DruidUtils.getConnection(),"select * from type;",new BeanListHandler<>(Type.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
